﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MessageBoxWidth2BtnController : MonoBehaviour {

    public GameObject m_kMask;
	public UILabel m_kLabel;
	public GameObject m_kOKBtn;
	public GameObject m_kCancelBtn;
	//public UILabel m_kBtnLabel;
	//public UILabel m_kCancelLabel;
    public UILabel titleLable;

    public List<UITweener> tweeners;
    

    public void OnMaskClick(GameObject obj)
    {
        gameObject.SetActive(false);
    }

	BoxManager.MessageBoxDelegate onClick = null;

	public void Init (string sLabel, bool isConfirmBtnLeft, BoxManager.MessageBoxDelegate onReponse){
		m_kLabel.text = sLabel;

		onClick = onReponse;
		
		if (!isConfirmBtnLeft){
            Vector3 p = m_kOKBtn.transform.localPosition;
            m_kCancelBtn.transform.localPosition = p;
            p.x = -p.x;
            m_kOKBtn.transform.localPosition = p;
		}

        foreach (var tweener in tweeners) {
            tweener.ResetToBeginning();
            tweener.PlayForward();
        }
    }

	
	public void Init (string sLabel, BoxManager.MessageBoxDelegate onReponse){
		Init(sLabel,true, onReponse);
	}
	
    public void Init(string sLabel,bool isConfirmBtnLeft, BoxManager.MessageBoxDelegate onReponse, string title)
    {
        titleLable.text = title;
        titleLable.gameObject.SetActive(true);
        Init(sLabel,isConfirmBtnLeft,onReponse);
    }

    public void Init(string sLabel, bool isConfirmBtnLeft, BoxManager.MessageBoxDelegate onReponse, string title,bool hasCancleBtn)
    {
        if(!hasCancleBtn)
        {
            m_kCancelBtn.SetActive(false);
            m_kOKBtn.transform.localPosition = new Vector3(0, -134, 0);
        }
        titleLable.text = title;
        titleLable.gameObject.SetActive(true);
        Init(sLabel, isConfirmBtnLeft, onReponse);
    }

    public void OnConfirmClick(GameObject obj){
		onClick (true);
        Destroy(gameObject);
        //UI.GuideManager.Instance.HideGuide();
    }

	public void OnCancelClick(GameObject obj){
		onClick (false);
        Destroy(gameObject);
        //UI.GuideManager.Instance.LocalGuideStep = 0;
        //UI.GuideManager.Instance.ActionGuide();
	}
}
